﻿package mortal.game.view.flowerSend.effect
{
    import baseEngine.modifiers.*;
    import com.gengine.resource.*;
    import com.gengine.resource.info.*;
    import com.mui.controls.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import frEngine.primitives.object2d.*;
    import frEngine.render.layer.*;
    import mortal.game.manager.window3d.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.pools.*;
    import mortal.game.view.common.*;

    public class FlowerPlayer extends EventDispatcher
    {
        private var _alpha:Number = 1;
        private var _txt:GImageBitmap;
        private var _nameBg:GImageBitmap;
        private var _name:GTextFiled;
        private var _flowerName:GTextFiled;
        private var _objInfo:Obj3dInfo;
        private var _bg2d:Img2D;
        private const effectSendName:String = "UI_songhua_blueheart";
        private const effectReceiveName:String = "UI_songhua_redheart";
        private var _x:Number = 0;
        private var _y:Number = 0;
        private var _effectName:String;
        private var _effectPlayer:EffectPlayer;
        private var _rect3d:Rect3DObject;
        private var _container:DisplayObjectContainer;
        public var loaded:Boolean = false;
        public static const receive:int = 1;
        public static const send:int = 2;

        public function FlowerPlayer(param1:Rect3DObject, param2:DisplayObjectContainer)
        {
            this._rect3d = param1;
            this._container = param2;
            return;
        }// end function

        public function get y() : Number
        {
            return this._y;
        }// end function

        public function set y(param1:Number) : void
        {
            if (this._y == param1)
            {
                return;
            }
            this._y = param1;
            if (this._name != null)
            {
                this._txt.y = this._y + 50;
                this._name.y = this._y + 77;
                this._nameBg.y = this._y + 75;
                this._flowerName.y = this._y + 53;
            }
            if (this._objInfo != null)
            {
                this._objInfo.offsetY = this._y;
                this._bg2d.y = this._y;
            }
            return;
        }// end function

        public function get x() : Number
        {
            return this._x;
        }// end function

        public function set x(param1:Number) : void
        {
            if (this._x == param1)
            {
                return;
            }
            this._x = param1;
            if (this._name != null)
            {
                this._nameBg.x = this._x - 2;
                this._name.x = this._x + 65;
                this._txt.x = this._x + 30;
                this._flowerName.x = this._x + 100;
            }
            if (this._objInfo != null)
            {
                this._objInfo.offsetX = this._x;
                this._bg2d.x = this._x;
            }
            return;
        }// end function

        public function set flowerName(param1:String) : void
        {
            return;
        }// end function

        public function set alpha(param1:Number) : void
        {
            this._alpha = param1;
            var _loc_2:* = param1;
            this._container.alpha = param1;
            var _loc_2:* = param1;
            this._bg2d.alpha = param1;
            return;
        }// end function

        public function get alpha() : Number
        {
            return this._alpha;
        }// end function

        public function setWinType(param1:int) : void
        {
            switch(param1)
            {
                case receive:
                {
                    this._txt.imgUrl = ImagesConst.FlowerTxt_6;
                    this._effectName = this.effectReceiveName;
                    LoaderManager.instance.load(GImageBitmap.getUrl(ImagesConst.FlowerSmallWinReceive), this.bgCompl);
                    break;
                }
                case send:
                {
                    this._txt.imgUrl = ImagesConst.FlowerTxt_7;
                    this._effectName = this.effectSendName;
                    LoaderManager.instance.load(GImageBitmap.getUrl(ImagesConst.FlowerSmallWinSend), this.bgCompl);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        public function createDisposedChildrenImpl() : void
        {
            this._txt = UIFactory.gImageBitmap("", 0, 0, this._container);
            this._nameBg = UIFactory.gImageBitmap(ImagesConst.FlowerTxtBg, 0, 50, this._container);
            this._name = UIFactory.gTextField("", 0, 0, 100, 50, this._container);
            this._flowerName = UIFactory.gTextField("", 0, 0, 100, 20, this._container);
            return;
        }// end function

        public function get effectPlayer() : EffectPlayer
        {
            return this._effectPlayer;
        }// end function

        public function set playerName(param1:String) : void
        {
            this._name.text = param1;
            return;
        }// end function

        public function disposeImpl(param1:Boolean = true) : void
        {
            this._txt.dispose();
            this._txt = null;
            this._name.dispose();
            this._name = null;
            this._nameBg.dispose(param1);
            this._nameBg = null;
            this._rect3d = null;
            var _loc_2:int = 1;
            this._container.alpha = 1;
            this._container = null;
            this._objInfo = null;
            this._bg2d = null;
            this.loaded = false;
            return;
        }// end function

        public function show(param1:Number, param2:Number, param3:Boolean = false) : void
        {
            if (param3)
            {
                (this._x + 1);
                (this._y + 1);
            }
            this.x = param1;
            this.y = param2;
            return;
        }// end function

        protected function bgCompl(param1:SWFInfo) : void
        {
            if (this._rect3d == null)
            {
                return;
            }
            this._bg2d = new Img2D(null, param1.bitmapData, new Rectangle(0, 0, param1.bitmapData.width, param1.bitmapData.height), true);
            this._rect3d.addImg(this._bg2d, Layer3DManager.AlphaLayer0);
            this._effectPlayer = EffectPlayerPool.instance.getEffectPlayer(this._effectName, null, this._rect3d.renderList, false);
            this._effectPlayer.play(PlayMode.ANIMATION_LOOP_MODE);
            this._objInfo = this._rect3d.addObject3d(this._effectPlayer, 101, 95);
            this.loaded = true;
            this.show(this._x, this._y, true);
            this.dispatchEvent(new Event(Event.COMPLETE));
            return;
        }// end function

    }
}
